Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disallow trailing letters when parsing decimal integer #204

Merged
merged 4 commits into from
Oct 4, 2021

Conversation

dgoffredo
Copy link
Contributor

@dgoffredo dgoffredo commented Oct 4, 2021

In internal support ticket APMS-6017, a customer has an old (Java) tracer that's producing trace_ids that are hexadecimal strings.

When the C++ tracer is parsing a trace_id from a header, it accepts any string that begins with decimal digits (possibly with leading whitespace), i.e. any string matching \s*[+]?(0|[1-9][0-9]+)([^0-9].*)?. This is due to the use of std::stoull.

In this pull request, I modify the parsing code to further require that the parsed decimal integer is followed by whitespace only. This way, decimal prefixes of hexadecimal trace_ids will fail to parse, rather than successfully parsing the decimal prefix.

These changes might break things. Let's discuss if/how to roll this out.

@dgoffredo dgoffredo requested a review from cgilmour October 4, 2021 17:24
Copy link
Contributor

@cgilmour cgilmour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, approved!

@dgoffredo dgoffredo merged commit fbdd1e5 into master Oct 4, 2021
@dgoffredo dgoffredo deleted the david.goffredo/strict-id-parsing branch October 4, 2021 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants